<!--_meta 作为公共模版分离出去-->
{include file="public/_meta"}


<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 消息管理 <span class="c-gray en">&gt;</span>可发消息列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <form action="" method="get">
        <div class="text-c">
            <input type="text" class="input-text" style="width:250px" placeholder="请输入用户名、姓名、电话" id="" name="keywords">
            <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="dataDel()" class="btn btn-danger  radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
                        <a href="javascript:;" onclick="batch_see()" class="btn btn-success  radius"><i class="Hui-iconfont">&#xe725;</i> 批量查看</a>
            <a href="javascript:;" onclick="all_see()" class="btn btn-primary  radius"><i class="Hui-iconfont">&#xe725;</i> 一键查看</a>
        </span>
        <span class="r">共有数据：<strong>{$count}</strong> 条</span> </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th >ID</th>
                <th >姓名</th>
                <th >标题</th>
                <th >消息内容</th>
                <th >消息时间</th>
                <th >消息状态</th>
                <th >操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="information" id="vo"}
            <tr class="text-c">
                <td><input type="checkbox" value="{$vo.id}" name="id[]"></td>
                <td>{$vo.id}</td>
                <td><a href="javascript:void(0);" style="cursor:pointer" class="text-primary" onclick="member_show('{$vo.full_name}','{:url(\'member/member_show\')}?id={$vo.user_id}','{$vo.user_id}','500','450')"><u><b>{$vo.full_name}</b></u></a></td>
                <td>{$vo.title|mb_substr=0,7,'utf-8'}</td>
                <td>{$vo.content|mb_substr=0,9,'utf-8'}...</td>
                <td>{$vo.create_time}</td>
                {if condition="$vo.status eq 0"}
                <td><span class="label label-warning radius">未查看</span></td>
                {elseif condition="$vo.status eq 1"/}
                <td><span class="label label-success radius">已查看</span></td>
                {/if}
                <td class="td-manage">
                    <a title="编辑" href="javascript:;" onclick="edit_information('编辑','{:url(\'information/edit_information\')}?id={$vo.id}','{$vo.id}','800','400')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                    <a title="删除" href="javascript:;" onclick="del_information(this,'{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    <a title="查看" href="javascript:;" onclick="see_information(this,'{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe725;</i></a>
                    <a title="清空相同消息" href="javascript:;" onclick="del_same_information(this,'{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont" style="color: red"><b>&#xe72a;</b></i></a>

                </td>
                </tr>
            {/volist}
            </tbody>
        </table>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer"}


<script type="text/javascript">
    $(function(){
        $('.table-sort').dataTable({
            "aaSorting": [[ 1, "asc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,6]}// 制定列不参与排序
            ]
        });

    });
    /*用户-查看*/
    function member_show(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*发送消息*/
    function edit_information(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*群发消息*/
    function add_information_mass(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*相同消息-删除*/
    function del_same_information(obj,id){
        layer.confirm('确认要清空相同内容的信息记录吗？',function(index){
            $.ajax({
                type: 'post',
                url: "{:url('information/del_same_information')}",
                dataType: 'json',
                data: {id:id},
                success: function(rec){
                    if(rec.status == true){
                        layer.msg(rec.message,{icon:6,time:1000});
                        setTimeout(jump,1000);
                        function jump(){
                            window.location.replace(location.href);
                        }
                    }else if(rec.status == false){
                        layer.msg(rec.message,{icon:5,time:1000});
                    }
                }
            });
        });
    }
    /*消息-删除*/
    function del_information(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'post',
                url: "{:url('information/del_information')}",
                dataType: 'json',
                data: {id:id},
                success: function(rec){
                    if(rec.status ==  true){
                        layer.msg(rec.message,{icon:1,time:1000});
                        setTimeout(jump,1000);
                        function jump(){
                            window.location.replace(location.href);
                        }
                    }else if(rec.status ==  false){
                        layer.msg(rec.message,{icon:5,time:1000});
                    }
                },
                error:function(rec) {
                    console.log(rec.msg);
                },
            });
        });
    }
    /*消息查看*/
    function see_information(obj,id){
        layer.confirm('确认要查看吗？',function(index){
            $.ajax({
                type: 'post',
                url: "{:url('information/see_information')}",
                dataType: 'json',
                data: {id:id},
                success: function(rec){
                    if(rec.status ==  true){
                        layer.msg(rec.message,{icon:1,time:1000});
                        setTimeout(jump,1000);
                        function jump(){
                            window.location.replace(location.href);
                        }
                    }else if(rec.status ==  false){
                        layer.msg(rec.message,{icon:5,time:1000});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
    //批量删除
    function dataDel(){
        layer.confirm('确认要删除吗？',function(index){
            var user_id =[];
            $('input[name="id[]"]:checked').each(function(){
                user_id.push($(this).val());
            });
            if(user_id.length==0){
                layer.msg('未选择删除项',{icon:5,time:1000});
            }else {
                $.ajax({
                    type: 'post',
                    url: "{:url('information/batch_del_information')}",
                    dataType: 'json',
                    data: {id:user_id},
                    success: function(rec){
                        if(rec.status ==  true){
                            layer.msg(rec.message,{icon:6,time:1000});
                            setTimeout(jump,1000);
                            function jump(){
                                window.location.replace(location.href);
                            }
                        }else if(rec.status ==  false){
                            layer.msg(rec.message,{icon:5,time:1000});
                        }
                    }
                });
            }

        });
    }
    /*一键查看*/
    function all_see(title,url,id,w,h){

        layer.confirm('确认要查看所有消息吗？',function(index){
            $.ajax({
                type: 'post',
                data:{id:1},
                url: "{:url('information/all_see')}",
                dataType: 'json',
                success: function(rec){
                    if(rec.status == true){
                        layer.msg(rec.message,{icon:6,time:1000});
                        setTimeout(jump,1000);
                        function jump(){
                            window.location.replace(location.href);
                        }
                    }else if(rec.status == false){
                        layer.msg(rec.message,{icon:5,time:1000});
                    }
                }
            });

        });
    }

    //批量查看
    function batch_see(){
        layer.confirm('确认要查看勾选的信息吗？',function(index){
            var user_id =[];
            $('input[name="id[]"]:checked').each(function(){
                user_id.push($(this).val());
            });
            if(user_id.length==0){
                layer.msg('未选择查看项',{icon:5,time:1000});
            }else {
                $.ajax({
                    type: 'post',
                    url: "{:url('information/batch_see')}",
                    dataType: 'json',
                    data: {id:user_id},
                    success: function(rec){
                        if(rec.status == true){
                            layer.msg(rec.message,{icon:6,time:1000});
                            setTimeout(jump,1000);
                            function jump(){
                                window.location.replace(location.href);
                            }
                        }else if(rec.status == false){
                            layer.msg(rec.message,{icon:5,time:1000});
                        }
                    }
                });
            }

        });
    }
</script>
